﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Fcdbas.CodeBuilder
{
    public partial class NewModel : Form
    {
        public NewModel()
        {
            InitializeComponent();
            //this.labName.Text = "Project Name";
            //this.Text = "Project";
        }


        public NewModel(int flag)
        {
            this.Flag = flag;
            InitializeComponent();
            //this.labName.Text = this.Flag == 0 ? "Project Name" : "Model Name";
            //this.Text = this.Flag == 0 ? "Project" : "Model";
        }


        /// <summary>
        /// 0,Project
        /// 1,Model
        /// </summary>
        public int Flag
        {
            get;
            set;
        }

        #region 按鈕事件方法
        private void button1_Click(object sender, EventArgs e)
        {
            SetMoudle();
        }

        void SetMoudle()
        {
            if (string.IsNullOrEmpty(this.txtName.Text))
            {
                return;
            }
            if (Flag == 0)
            {
                (this.Owner as Fcdbas.Tool.CodeBuilder).ProjectName = this.txtName.Text;
            }
            if (Flag == 1)
            {
                (this.Owner as Fcdbas.Tool.CodeBuilder).MoudleName = this.txtName.Text;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
        #endregion

        private void txtName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                SetMoudle();
            }
        }
    }
}
